<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>消息中心</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layadmin/style/admin.css" media="all">
</head>

<body>
    <div class="layui-fluid" id="LAY-app-message">
        <div class="layui-card">
            <div class="layui-tab layui-tab-brief">
                <ul class="layui-tab-title">
                    <li class="layui-this">站点配置</li>
                    <!-- <li>联系方式</li> -->
           <!--          <li>联系我们</li>
                    <li>短信配置</li>
                    <li>应用配置</li> -->
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <div class="layui-form" wid100 lay-filter="">
                            <div class="layui-form-item">
                                <label class="layui-form-label">网站名称<span style="color: red;">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="sitename" value="{$mess.sitename}" class="layui-input" lay-verify="required">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">公司名称<span style="color: red;">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="company" value="{$mess.company}" class="layui-input" lay-verify="required">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">网站域名<span style="color: red;">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="domain" value="{$mess.domain}" class="layui-input" lay-verify="required">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">网站LOGO<span style="color: red;">*</span></label>
                                <div class="layui-input-inline" style="width:30%;">
                                  <input type="text" name="logo" id="filepath" value="{$mess.logo}" subId="{$mess.logo}" class="layui-input" lay-verify="required">
                                  <!-- <input type="hidden" name="annexes">                                  -->
                              </div>
                              <div class="layui-form-mid layui-word-aux" style="padding:0px !important;">
                                  <button type="button" class="layui-btn" id="test-upload-type1"><i class="layui-icon"></i>上传图片</button>
                              </div>
                            </div>
                            <div class="layui-form-item layui-form-text">
                                <label class="layui-form-label">META标题</label>
                                <div class="layui-input-block">
                                    <textarea name="title" class="layui-textarea">{$mess.title}</textarea>
                                </div>
                            </div>
                            <div class="layui-form-item layui-form-text">
                                <label class="layui-form-label">META关键词</label>
                                <div class="layui-input-block">
                                    <textarea name="keywords" class="layui-textarea" placeholder="多个关键词用英文状态 , 号分割">{$mess.keywords}</textarea>
                                </div>
                            </div>
                            <div class="layui-form-item layui-form-text">
                                <label class="layui-form-label">META描述</label>
                                <div class="layui-input-block">
                                    <textarea name="descript" class="layui-textarea">{$mess.descript}</textarea>
                                </div>
                            </div>
                            <div class="layui-form-item layui-form-text">
                                <label class="layui-form-label">ICP备案<span style="color: red;">*</span></label>
                                <div class="layui-input-inline">
                                    <input type="text" name="icp" value="{$mess.icp}" class="layui-input" lay-verify="required">
                                </div>
                            </div>
                            <div class="layui-form-item layui-form-text">
                                <label class="layui-form-label">版权信息<span style="color: red;">*</span></label>
                                <div class="layui-input-block">
                                    <textarea name="copyright" class="layui-textarea" placeholder="©2021 虎一窝." lay-verify="required">{$mess.copyright}</textarea>
                                    <div class="layui-form-mid layui-word-aux">标准格式：<b style="color: red;">Copyright 2021 ruochen.All rights Reserved.</b>
                                        <!-- 。其中Copyright可简化为©；date网站创建至今的年份，也可以只写当前年份；author/owner为作者或所有者；All rights Reserved.所有权声明可不写,也可以写成版权所有。 -->
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <input type="hidden" name="updid" value="{$mess.id}">
                                    <button class="layui-btn" lay-submit lay-filter="set_website">确认保存</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="/static/layadmin/layui/layui.js"></script>
    <script>
    layui.config({
        base: '/static/layadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'upload','form'], function() {
        var $ = layui.jquery,
            upload = layui.upload,
            form = layui.form;

        var uploadInst = upload.render({
            elem: '#test-upload-type1',
            url: '/admin/base/default_upload', //改成您自己的上传接口
            accept: 'file',
            // acceptMime:'application/msword,image/gif,image/x-icon,image/jpeg,video/mpeg4,application/pdf,application/x-png,application/x-ppt,application/x-xls,application/x-ico,audio/mp3,image/png,application/vnd.ms-powerpoint,application/x-ppt,text/plain,application/vnd.ms-excel' ,
            acceptMime: 'image/jpeg,image/gif,image/png,image/x-icon',
            size: 10240, //限制文件大小，单位 KB
            before: function(obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result) {

                    var point = file.type.lastIndexOf("/");

                    var type = file.type.substr(point + 1);
                    console.log(point);
                    console.log(type);

                    $('#showfile').html('<img src="' + result + '">');


                    // $('#demo1').attr('src', result); //图片链接（base64）
                });
            },
            done: function(res) {
                console.log(res);
                if (res.code > 0) {
                    
                    layer.msg(res.msg, { icon: 6 }, function() {
                        $('#filepath').val(res.filename);
                    });
                } else {
                    return layer.msg('上传失败');
                }
                //上传成功
            },
            error: function() {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function() {
                    uploadInst.upload();
                });
            }
        });
        upload.render({
            elem: '#test-upload-type2',
            url: '/admin/base/upload_file', //改成您自己的上传接口
            accept: 'file',
            // acceptMime:'application/msword,image/gif,image/x-icon,image/jpeg,video/mpeg4,application/pdf,application/x-png,application/x-ppt,application/x-xls,application/x-ico,audio/mp3,image/png,application/vnd.ms-powerpoint,application/x-ppt,text/plain,application/vnd.ms-excel' ,
            acceptMime: 'image/jpeg,image/gif,image/png,image/x-icon',
            size: 2048, //限制文件大小，单位 KB
            before: function(obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result) {

                    var point = file.type.lastIndexOf("/");

                    var type = file.type.substr(point + 1);
                    // console.log(point);
                    // console.log(type);

                    $('#showqrcode').html('<img src="' + result + '">');


                    // $('#demo1').attr('src', result); //图片链接（base64）
                });
            },
            done: function(res) {
                console.log(res);
                if (res.code > 0) {
                    $('#qrcodepath').val(res.filename);
                } else {
                    return layer.msg('上传失败');
                }
                //上传成功
            },
            error: function() {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function() {
                    uploadInst.upload();
                });
            }
        });
        //监听提交
        form.on('submit(set_website)', function(data) {
            var field = data.field; //获取提交的字段
            // var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引  
            // layer.msg('表单已提交');
            // console.log(field);
            // var thumb = $("#filepath").attr("subId");
            //提交 Ajax 成功后，关闭当前弹层并重载表格
            $.post('/admin/systemt/indexAddDone/updid/' + field.updid, { sitename: field.sitename, company:field.company,domain: field.domain, logo: field.logo, title: field.title , keywords: field.keywords, descript: field.descript, icp: field.icp, copyright: field.copyright}, function(res) {
                res = $.parseJSON(res);
                console.log(res.code);
                if (res.code == 200) {
                    layer.msg(res.msg, {
                        icon: 1,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function() {                       
                        window.location.reload();
                    });
                } else {
                    layer.msg(res.msg, { icon: 2, time: 2000 });
                }
            });
        });
        form.on('submit(set_upload)', function(data) {
            var field = data.field; //获取提交的字段
            // var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引  
            // layer.msg('表单已提交');
            // console.log(field);
            //提交 Ajax 成功后，关闭当前弹层并重载表格
            $.post('/admin/systemt/indexAddDone/updid/' + field.updid, { cache_time: field.cache_time, upload_max: field.upload_max, upload_type: field.upload_type }, function(res) {
                res = $.parseJSON(res);
                console.log(res.code);
                if (res.code == 200) {
                    layer.msg(res.msg, {
                        icon: 1,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function() {
                        window.location.reload();
                    });
                } else {
                    layer.msg(res.msg, { icon: 2, time: 2000 });
                }
            });
        });
        form.on('submit(set_system_contact)', function(data) {
            var field = data.field; //获取提交的字段
            // var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引  
            // layer.msg('表单已提交');
            // console.log(field);
            //提交 Ajax 成功后，关闭当前弹层并重载表格
            $.post('/admin/systemt/indexAddDone/updid/' + field.updid, { contact: field.contact, tel: field.tel, email: field.email, qq: field.qq , address: field.address, qrcode: field.qrcode ,location:field.location}, function(res) {
                res = $.parseJSON(res);
                console.log(res.code);
                if (res.code == 200) {
                    layer.msg(res.msg, {
                        icon: 1,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function() {
                        window.location.reload();
                    });
                } else {
                    layer.msg(res.msg, { icon: 2, time: 2000 });
                }
            });
        });

        $('#filepath').on('click', function () {
          var thumb = $(this).val();
          window.open(thumb);
          // if(thumb){
          //   layer.open({
          //     type: 1, 
          //     title: '图片查看',
          //     skin:'text-align', 
          //     content: '<img src="'+thumb+'"  />', //这里content是一个普通的String
          //     area: ['100%', '100%']
          //   });
          // }
        });
    });
    </script>
</body>

</html>